package com.example.springboot.service.impl;


import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.springboot.entity.DeviceState;
import com.example.springboot.mapper.DeviceStateMapper;
import com.example.springboot.service.IDeviceStateService;
import org.springframework.stereotype.Component;


@Component
public class DeviceStateServiceImpl extends ServiceImpl<DeviceStateMapper, DeviceState> implements IDeviceStateService {
    private final static String str = "好的，deviceNameAB相电压abVoltage，BC相电压bcVoltage，AC相电压acVoltage，A相电流aCurrent，B相电流bCurrent，C相电流cCurrent，轴承温度bearingTemperature，电压电流温度正常，查询完毕！";

    @Override
    public String selectDeviceState(String deviceName,String parameterType) {

        DeviceState deviceState = baseMapper.selectOne(Wrappers.<DeviceState>query().lambda().eq(DeviceState::getDeviceName, deviceName));
        if(parameterType==null){
            if(deviceState==null){
                return "无法理解要查询的数据。";
            }
            return  "好的，"+deviceName +"的AB相电压"+deviceState.getAbVoltage()+"，BC相电压"+deviceState.getBcVoltage()+"，AC相电压"+deviceState.getAcVoltage()+"，A相电流"+deviceState.getaCurrent()+"，B相电流"+deviceState.getbCurrent()+"，C相电流"+deviceState.getcCurrent()+"，轴承温度"+deviceState.getBearingTemperature()+"，电压电流温度正常，查询完毕！";
        }
        if(deviceState==null){
            return "无法理解要查询的数据。";
        }
        if(parameterType.equalsIgnoreCase("AB相电压")){
            return  "好的，"+deviceName +"的"+parameterType+"为："+deviceState.getAbVoltage();
        }else if(parameterType.equalsIgnoreCase("BC相电压")){
            return  "好的，"+deviceName +"的"+parameterType+"为："+deviceState.getBcVoltage();
        }else if(parameterType.equalsIgnoreCase("AC相电压")){
            return  "好的，"+deviceName +"的"+parameterType+"为："+deviceState.getAcVoltage();
        }else if(parameterType.equalsIgnoreCase("A相电流")){
            return  "好的，"+deviceName +"的"+parameterType+"为："+deviceState.getaCurrent();
        }else if(parameterType.equalsIgnoreCase("B相电流")){
            return  "好的，"+deviceName +"的"+parameterType+"为："+deviceState.getbCurrent();
        }else if(parameterType.equalsIgnoreCase("C相电流")){
            return  "好的，"+deviceName +"的"+parameterType+"为："+deviceState.getcCurrent();
        } else if(parameterType.equalsIgnoreCase("轴承温度")){
            return  "好的，"+deviceName +"的"+parameterType+"为："+deviceState.getBearingTemperature();
        }

        return "无法理解要查询的数据。";
    }
}
